function request(url,data={},method='GET',contentType) {
    const promise = new Promise((resolve, reject) => {
        const client = new XMLHttpRequest();
        const handler = () =>{
            if (client.readyState !== 4) {
                return;
            }
            if (client.status === 200) {
                resolve(client.response);
            } else {
                reject(new Error(client.statusText));
            }
        };
        client.open(method, url);
        client.onreadystatechange = handler;
        client.responseType = "json";
        if(contentType) {//application/json
            data = JSON.stringify(data);
            client.setRequestHeader("Content-type",contentType);
        }
        // client.setRequestHeader("Accept", "application/json");
        client.send(data);

    });

    return promise;
}